<?php
if (isset($_POST['first_name'])) {
    $first_name = $_POST['first_name'];
}

if (isset($_POST['mid_name'])) {
    $mid_name = $_POST['mid_name'];
}

if (isset($_POST['last_name'])) {
    $last_name = $_POST['last_name'];
}
if (isset($_POST['username'])) {
    $username = $_POST['username'];
}
if (isset($_POST['password'])) {
    $password = $_POST['password'];
}
if (isset($_POST['con_password'])) {
    $con_password = $_POST['con_password'];
}
if (isset($_POST['email'])) {
    $email = $_POST['email'];
}
if (isset($_POST['gender'])) {
    $gender = $_POST['gender'];
}
if (isset($_POST['mm'])) {
    $mm = $_POST['mm'];
}
if (isset($_POST['dd'])) {
    $dd = $_POST['dd'];
}
if (isset($_POST['yy'])) {
    $yy = $_POST['yy'];
}
if (isset($_POST['country'])) {
    $country = $_POST['country'];
}
if (isset($_POST['colz_work'])) {
    $colz_work = $_POST['colz_work'];
}
if (isset($_POST['website'])) {
    $website = $_POST['website'];
}


if ($first_name != "" && $last_name != "" && $username != "" && $password != "" && $email != "" && $gender != "" && $mm != "" && $dd != "" && $yy != "" && $country != "" ) {
    if($password !=$con_password) {
        echo "Password didn't match! Please type the exact same passwords";
    }
    else {
        $dob="$yy-$mm-$dd";
        $fullname="$first_name $mid_name $last_name";
        $now = time();

        mysql_connect("localhost","root","");
        mysql_select_db("susudo");

        $profile_query="INSERT INTO `users` (`id`,  `username`, `password`, `email`, `created_at`,`updated_at`)
        VALUES (NULL,'$username', '$password', '$email', $now, $now );";
        mysql_query($profile_query);
        $user_id = mysql_insert_id();
        
        $user_query="INSERT INTO `users_profile` (`id`, `user_id`,`salutation`, `about`,`profile_pic`,`first_name`, `mid_name`,`last_name`, `gender`, `country`, `college`,`website`,`dob`)
        VALUES (NULL,$user_id,NULL,NULL,NULL,'$first_name', '$mid_name', '$last_name', '$gender', '$country', '$colz_work', '$website','$dob');";
        mysql_query($user_query);

        mysql_close();

        header("location: ../frontend.php");
        //echo "<p style='color:#00f'>Hi, $fullname, thanks for the information. </p> ";


    }}
    else {
        echo "<p style='color:red'>Please provide all ur infromation properly </p>";
}

